﻿using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class MainMenu : MonoBehaviour
{
    public Sprite iconOpen;
    public Sprite iconClose;
    public Image Music;
    // Use this for initialization
    void Start()
    {
        CheckMusic();
    }
    void CheckMusic() {
        if(PlayerPrefs.GetInt(GamePreference.Music) == 1) {
            Music.sprite = iconOpen;
        }else {
            Music.sprite = iconClose;
        }

        MusicController.Instance.CheckMusic();
    }
    // Update is called once per frame
    void Update()
    {
	
    }

    public void StartGame()
    {
        SceneManager.LoadScene("GamePlay");
    }

    public void HighScore()
    {
        SceneManager.LoadScene("highScore");
    }

    public void Options()
    {
        SceneManager.LoadScene("option");
    }

    public void Quit()
    {
        Application.Quit();
    }

    public void Sound()
    {
        var state = PlayerPrefs.GetInt(GamePreference.Music);
        if(state == 0) {
            PlayerPrefs.SetInt(GamePreference.Music, 1);
        }else {
            PlayerPrefs.SetInt(GamePreference.Music, 0);
        }
        CheckMusic();
    }
}
